package org.android.animation;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class AnimationUtil {
	public static void goneAfterAnimation(Activity pContext, int pViewID, int pAnimationID,int startOffset) {
		final Animation loadAnimation = AnimationUtils.loadAnimation(
				pContext, pAnimationID);
		loadAnimation.setStartOffset(startOffset);
		final View view = pContext.findViewById(pViewID);
		view.startAnimation(loadAnimation);
		loadAnimation.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {

			}

			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			@Override
			public void onAnimationEnd(Animation animation) {
				view.setVisibility(View.GONE);

			}
		});
	}
	public static void goneAfterAnimation(Activity pContext, int pViewID, int pAnimationID) {
		goneAfterAnimation(pContext, pViewID, pAnimationID,0);
	}

	public static void frameAnimation(Activity mainActivity, int pViewID, int pAnimationID) {
		ImageView animationIV = (ImageView)mainActivity.findViewById(pViewID);  
	    animationIV.setBackgroundResource(pAnimationID);  
	    AnimationDrawable AniDraw = (AnimationDrawable)animationIV.getBackground();
	    AniDraw.start();
		
	}
}
